import stocknews
import time

articles = stocknews.StockNews(db_file_name='data/_stocknews_db_639-stocks_2011-10-15-2013-10-15.shelve')

print "Getting a single data point"
print "---------------------------"

start_time = time.clock()
print articles.iterate(['stock_short_name', 'datetime']).next()
print time.clock() - start_time

start_time = time.clock()
print zip(articles.iterate('stock_short_name'), articles.iterate('datetime'))[0]
print time.clock() - start_time

print "which correspond to 2 times:"
start_time = time.clock()
print [x for x in articles.iterate(['stock_short_name'])][0]
print time.clock() - start_time

print
print "Getting a all data point"
print "---------------------------"

start_time = time.clock()
for x in articles.iterate(['stock_short_name', 'datetime']):
    pass
print time.clock() - start_time

start_time = time.clock()
zip(articles.iterate('stock_short_name'), articles.iterate('datetime'))
print time.clock() - start_time

print "which correspond to 2 times:"
start_time = time.clock()
[x for x in articles.iterate(['stock_short_name'])]
print time.clock() - start_time
